package com.ocom.nettyxf.vo;

import com.ocom.common.utils.NumConvertUtil;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: TODO
 * @Author: 朱晖
 * @Date: 2022/10/24
 **/
@Data
public class FkVo {
	//响应结果
	String code = "0000" ;


	//JobID
	String jobId = "000000000000";

	//0-不允许离线消费，1-允许
	String offlineMode = "00";

	//机具允许离线总金额
	String offlineAmount = "00000000";

	//机具允许离线总笔数
	String offlineOrderNum = "00000000";

	//机具允许离线总时长
	String offlineTime = "00000000";

	//身份类型个数
	String identityLen = "00";

	List<FkUserVo>  list =new ArrayList<>();

	public void setJobId(String jobId) {
		if(jobId.length()<12){
			for(int i=jobId.length();i<12;i++){
				jobId ="0"+jobId;
			}
		}
		this.jobId = jobId;
	}

	public String getHexStr() throws Exception {
		identityLen = NumConvertUtil.IntToHexStringNum(list.size(), 2);
		String result = code
				+jobId
				+offlineMode
				+offlineAmount
				+offlineOrderNum
				+offlineTime
				+identityLen ;
		for (FkUserVo fkUserVo : list){
			result += fkUserVo.getIdentity();
			result += fkUserVo.getAmount();
			result += fkUserVo.getOrderAmount();
			result += fkUserVo.getOrderNum();
			result += fkUserVo.getDiscount();
		}
		return  result;
	}


}
